﻿<%@ Page Language="C#" AutoEventWireup="true" Culture="en-GB" CodeFile="EditPurchaseOrder.aspx.cs"
    Inherits="Main_Inventory_EditPurchaseOrder" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Src="~/User Controls/MCalender.ascx" TagPrefix="mcal" TagName="Calender" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Purchase Manager</title>
    <link rel="Stylesheet" href="../../Styles/accounts.css" type="text/css" />
    <link href="../../Styles/ComboBox.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/HorizontalTab.css" rel="stylesheet" type="text/css" />
    <script src="../../JavaScript/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="../../JavaScript/HorizontalTab.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        function showMsg() {
            alert('Purchase Order Edited SuccessFully.... !');
            window.location = "PurchaseOrder.aspx?View=True";
        }
        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                return false;
            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
        function calcQty() {
            var Count = document.getElementById("hidControl").value;
            var total_qty = 0;
            for (var i = 1; i <= Count; i++) {
                var qty = 0;
                if (document.getElementById("txtQty" + i).value != '') {
                    qty = parseFloat(document.getElementById("txtQty" + i).value);
                    document.getElementById("txtQty" + i).value = qty.toFixed(0);
                }
                total_qty += qty;
            }
            document.getElementById("txtTotalItem").value = total_qty.toFixed(2);
        }
        function calcRateExcl() {
            var Count = document.getElementById("hidControl").value;
            for (var i = 1; i <= Count; i++) {
                var qty = 0;
                if (document.getElementById("txtRateExcTax" + i).value != '') {
                    qty = parseFloat(document.getElementById("txtRateExcTax" + i).value);
                    document.getElementById("txtRateExcTax" + i).value = qty.toFixed(5);
                }
            }
        }
        function calcAmt() {
            var Count = document.getElementById("hidControl").value;
            var Amountpayble = 0;
            var taxableamount = 0;
            var posttaxtotal = 0;
            for (var i = 1; i <= Count; i++) {
                if (document.getElementById("txtQty" + i).value != '') {
                    if (document.getElementById("txtRateExcTax" + i).value != '') {
                        Amountpayble = parseFloat(document.getElementById("txtQty" + i).value) * parseFloat(document.getElementById("txtRateExcTax" + i).value);
                        document.getElementById("txtAmountPayable" + i).value = Amountpayble.toFixed(5);
                        taxableamount += parseFloat(document.getElementById("txtAmountPayable" + i).value);
                    }
                    else {
                        document.getElementById("txtAmountPayable" + i).value = '0.00000';
                    }
                }
                else {
                    //document.getElementById("txtAmountPayable" + i).value = '0.00';
                }
            }
            document.getElementById("txtTaxableAmt").value = taxableamount.toFixed(5);
            document.getElementById("txtPostTaxTotal").value = taxableamount.toFixed(5);
            document.getElementById("txtGrandTotal").value = parseFloat(parseFloat(taxableamount) + parseFloat(document.getElementById("txtRoundoff").value)).toFixed(2);
        }

        function CreditDays() {
            if (document.getElementById("txtCreditDay").value != '') {
                var days = document.getElementById("txtCreditDay").value;
                if (parseFloat(days) > 365) {
                    alert('Maximum Credit Days is 365 days');
                    document.getElementById("txtCreditDay").value = '365';
                }
                document.getElementById("radioCash").checked = false;
                document.getElementById("radioCredit").checked = true;
            }
            else {
                document.getElementById("radioCash").checked = true;
                document.getElementById("radioCredit").checked = false;
            }
        }


        function RoundOff() {
            var posttax = document.getElementById("txtPostTaxTotal").value;
            if (document.getElementById("txtRoundoff").value != '') {
                var roundoff = document.getElementById("txtRoundoff").value;
                var GrandTotal = parseFloat(posttax) + parseFloat(roundoff);
                document.getElementById("txtGrandTotal").value = GrandTotal;
            }
            else {
                document.getElementById("txtRoundoff").value = '0.00'
                document.getElementById("txtGrandTotal").value = parseFloat(posttax).toFixed(2);
            }
        }

        function ValidateItems() {
            var flag = new Boolean(true);
            //For Check the Mode of Dispatch
            var ModeDispatch = document.getElementById("RblModeDispatch").getElementsByTagName("input");
            var ModeDispatchValue = '';
            for (var j = 0; j < ModeDispatch.length; j++) {
                //alert(ModeDispatch[j].checked);
                if (ModeDispatch[j].checked) {
                    ModeDispatchValue = ModeDispatch[j].value;
                }
            }
            //For Check the Acceptance Criteria
            var AcceptanceCriteria = document.getElementById("RblAcceptanceCriteria").getElementsByTagName("input");
            var AcceptanceCriteriaValue = '';
            for (var j = 0; j < AcceptanceCriteria.length; j++) {
                if (AcceptanceCriteria[j].checked) {
                    AcceptanceCriteriaValue = AcceptanceCriteria[j].value;
                }
            }
            //For Check the Validity of PO
            var ValidityOFPO = document.getElementById("RblvalidityofPO").getElementsByTagName("input");
            var ValidityOFPOValue = '';
            for (var j = 0; j < ValidityOFPO.length; j++) {
                if (ValidityOFPO[j].checked) {
                    ValidityOFPOValue = ValidityOFPO[j].value;
                }
            }
            //For Check the Insurance
            var Insurance = document.getElementById("RblInsurance").getElementsByTagName("input");
            var InsuranceValue = '';
            for (var j = 0; j < Insurance.length; j++) {
                if (Insurance[j].checked) {
                    InsuranceValue = Insurance[j].value;
                }
            }
            //For Freight
            var Freights = document.getElementById("RBLFreight").getElementsByTagName("input");
            var FreightValue = '';
            for (var j = 0; j < Freights.length; j++) {
                if (Freights[j].checked) {
                    FreightValue = Freights[j].value;
                }
            }
            //For Check the Warranty
            var Warranty = document.getElementById("RblWarranty").getElementsByTagName("input");
            var WarrantyValue = '';
            for (var j = 0; j < Warranty.length; j++) {
                if (Warranty[j].checked) {
                    WarrantyValue = Warranty[j].value;
                }
            }
            if (document.getElementById("ddlFormat").selectedIndex == 0) {
                alert('Please Select Bill Format ');
                document.getElementById("ddlFormat").focus();
                return false;
            }
            else if (document.getElementById("ddlSupplier").selectedIndex == 0) {
                alert('Please Select Supplier ');
                document.getElementById("ddlSupplier").focus();
                return false;
            } else if (document.getElementById("DdlLocation").selectedIndex == 0) {
                alert('Please Select Delivery Location.');
                document.getElementById("DdlLocation").focus();
                return false;
            } else if (document.getElementById("ddlleased").selectedIndex == 0) {
                alert('Please Select Leased Type  ');
                document.getElementById("ddlleased").focus();
                return false;
            }
            else if (document.getElementById("ddlcurrency").selectedIndex == 0) {
                alert('Please Select Currency.');
                document.getElementById("ddlcurrency").focus();
                return false;
            }
            else if (document.getElementById("txtBillAddress").value == '') {
                alert('Please Enter Billing Address.');
                document.getElementById("txtBillAddress").focus();
                return false;
            }
            else if (document.getElementById("txtDeliveryAdd").value == '') {
                alert('Please Enter Delivery Address.');
                document.getElementById("txtDeliveryAdd").focus();
                return false;
            }
            else if (document.getElementById("txtDeliveryTerms").value == '' && document.getElementById("ddlFormat").selectedIndex == 2) {
                    alert('Please Enter Delivery Terms From Other Tab.');
                    document.getElementById("txtDeliveryTerms").focus();
                    return false;                
            }
            //For International
            else if (document.getElementById("ddlDeliveryTerms").selectedIndex == 0 && document.getElementById("ddlFormat").selectedIndex == 1) {
                    alert('Please Select Delivery Terms From Other Tab.');
                    document.getElementById("ddlDeliveryTerms").focus();
                    return false;                
            }
            else if (document.getElementById("txttaxDuties").value == '') {
                alert('Please Enter Tax Duties.');
                document.getElementById("txttaxDuties").focus();
                return false;
            }
            else if (document.getElementById("txtDeliveryDate").value == '') {
                alert('Please Enter Delivery Date.');
                document.getElementById("txtDeliveryDate").focus();
                return false;
            }
            else if (ModeDispatchValue == '') {
                alert("Please Select the Mode of Dispatch");
                return false;
            }
            else if (ModeDispatchValue == 0 && document.getElementById("txtModeDispatch").value == '') {
                alert('Please Enter Mode Of Dispatch.');
                //document.getElementById("txtModeDispatch").focus();
                return false;
            }
            else if (AcceptanceCriteriaValue == '') {
                alert("Please Select the Acceptance Criteria");
                return false;
            }
            else if (AcceptanceCriteriaValue == '0' && document.getElementById("txtAcceptanceCriteria").value == '') {
                alert('Please Enter Acceptance Criteria.');
                document.getElementById("txtAcceptanceCriteria").focus();
                return false;
            }
            else if (ValidityOFPOValue == '') {
                alert("Please Select the Validity Of PO");
                return false;
            }
            else if (ValidityOFPOValue == 0 && document.getElementById("txtvalidityofPO").value == '') {
                alert('Please Enter Validity Of PO.');
                document.getElementById("txtvalidityofPO").focus();
                return false;
            }
            else if (InsuranceValue == '') {
                alert("Please Select the Insurance");
                return false;
            }
            else if (InsuranceValue == 0 && document.getElementById("txtInsurance").value == '') {
                alert('Please Enter Insurance.');
                document.getElementById("txtInsurance").focus();
                return false;
            }
            else if (WarrantyValue == '') {
                alert("Please Select the Warranty");
                return false;
            }
            else if (WarrantyValue == 0 && document.getElementById("txtWarranty").value == '') {
                alert('Please Enter Warranty.');
                document.getElementById("txtWarranty").focus();
                return false;
            }
            else if (document.getElementById("txtanyspecialcondition").value == '') {
                alert('Please Enter Any Special Condition.');
                document.getElementById("txtanyspecialcondition").focus();
                return false;
            }
            else if (document.getElementById("txtfreightfwd").value == '') {
                alert('Please Enter Freight Forwader.');
                document.getElementById("txtfreightfwd").focus();
                return false;
            }
            else if (document.getElementById("txtimpacno").value == '') {
                alert('Please Enter Import Account Number.');
                document.getElementById("txtimpacno").focus();
                return false;
            }
            else if (FreightValue == '') {
                alert("Please Select the Freights");
                return false;
            }
            else if (FreightValue == 0 && document.getElementById("txtfreight").value == '') {
                alert('Please Enter Freight.');
                document.getElementById("txtfreight").focus();
                return false;
            }
            else {
                return true;
            }
            //return flag;
        }
        function ValidateItems1() {
            //var flag=new Boolean(true);
            var Count = document.getElementById("hidControl").value;
            var set = 0;
            for (var i = 1; i <= Count; i++) {
                if (document.getElementById("txtItem" + i).value == '' && document.getElementById("txtQty" + i).value == '' && document.getElementById("txtRateIncTax" + i).value == '' && document.getElementById("ddlTaxType" + i).selectedIndex == 0) {
                    set = set + 1;
                }
                if (set == Count) {
                    alert('Please Create At least one Item');
                    document.getElementById("txtItem1").focus();
                    return false;
                }
            }
            if (Count > set) {
                for (var i = 1; i <= Count; i++) {
                    if (document.getElementById("txtItem" + i).value != '') {
                        if (document.getElementById("txtQty" + i).value == '' || document.getElementById("txtQty" + i).value == 0) {
                            alert('Please Specify Quantity at Row No ' + ' ' + i);
                            document.getElementById("txtQty" + i).focus();
                            return false;
                        }
                        if (document.getElementById("ddlleased").selectedIndex == 1)//Owned
                        {
                            if (document.getElementById("txtRateExcTax" + i).value == '' || document.getElementById("txtRateExcTax" + i).value == 0) {
                                alert('Please Specify Rate Exclusive Tax at Row No ' + ' ' + i);
                                document.getElementById("txtRateExcTax" + i).focus();
                                return false;
                            }
                        }
                        if (document.getElementById("ddlleased").selectedIndex == 2) //Consigned
                        {
                            if (document.getElementById("txtRateExcTax" + i).value == '') {
                                alert('Please Specify Rate Exclusive Tax at Row No ' + ' ' + i);
                                document.getElementById("txtRateExcTax" + i).focus();
                                return false;
                            }
                        }
                        if (document.getElementById("ddlFormat").selectedIndex == 1)//for Domestic
                        {
                            if (document.getElementById("ddlTaxType" + i).selectedIndex == 0) {
                                alert('Please Specify VAT/CST at Row no ' + '' + i);
                                document.getElementById("ddlTaxType" + i).focus();
                                return false;
                            }
                        }
                    }
                    else if (document.getElementById("txtQty" + i).value != '') {
                        if (document.getElementById("txtItem" + i).value == '') {
                            alert('Please Specify Item in Row No ' + ' ' + i);
                            document.getElementById("txtItem" + i).focus();
                            return false;
                        }
                        if (document.getElementById("ddlleased").selectedIndex == 1)//Owned
                        {
                            if (document.getElementById("txtRateExcTax" + i).value == '' || document.getElementById("txtRateExcTax" + i).value == 0) {
                                alert('Please Specify Rate Exclusive Tax at Row No ' + ' ' + i);
                                document.getElementById("txtRateExcTax" + i).focus();
                                return false;
                            }
                        }
                        if (document.getElementById("ddlleased").selectedIndex == 2) //Consigned
                        {
                            if (document.getElementById("txtRateExcTax" + i).value == '') {
                                alert('Please Specify Rate Exclusive Tax at Row No ' + ' ' + i);
                                document.getElementById("txtRateExcTax" + i).focus();
                                return false;
                            }
                        }
                        if (document.getElementById("ddlFormat").selectedIndex == 1)//for Domestic
                        {
                            if (document.getElementById("ddlTaxType" + i).selectedIndex == 0) {
                                alert('Please Specify VAT/CST at Row no ' + '' + i);
                                document.getElementById("ddlTaxType" + i).focus();
                                return false;
                            }
                        }
                    }
                    else if (document.getElementById("txtRateExcTax" + i).value != '') {
                        if (document.getElementById("txtQty" + i).value == '' || document.getElementById("txtQty" + i).value == 0) {
                            alert('Please Specify Quantity in Row No ' + ' ' + i);
                            document.getElementById("txtQty" + i).focus();
                            return false;
                        }
                        if (document.getElementById("txtItem" + i).value == '') {
                            alert('Please Specify Item in Row No ' + ' ' + i);
                            document.getElementById("txtItem" + i).focus();
                            return false;
                        }
                        if (document.getElementById("ddlFormat").selectedIndex == 1)//for Domestic
                        {
                            if (document.getElementById("ddlTaxType" + i).selectedIndex == 0) {
                                alert('Please Specify VAT/CST at Row no ' + '' + i);
                                document.getElementById("ddlTaxType" + i).focus();
                                return false;
                            }
                        }
                    }
                    else if (document.getElementById("ddlTaxType" + i).selectedIndex != 0) {
                        if (document.getElementById("ddlFormat").selectedIndex == 1)//for Domestic
                        {
                            if (document.getElementById("txtItem" + i).value == '') {
                                alert('Please Specify Item in Row No ' + ' ' + i);
                                document.getElementById("txtItem" + i).focus();
                                return false;
                            }
                            if (document.getElementById("txtRateExcTax" + i).value == '' || document.getElementById("txtRateExcTax" + i).value == 0) {
                                alert('Please Specify Rate Exclusive Tax at Row No ' + ' ' + i);
                                document.getElementById("txtRateExcTax" + i).focus();
                                return false;
                            }
                            if (document.getElementById("txtQty" + i).value == '' || document.getElementById("txtQty" + i).value == 0) {
                                alert('Please Specify Quantity in Row No ' + ' ' + i);
                                document.getElementById("txtQty" + i).focus();
                                return false;
                            }
                        }
                    }
                }
            }
            return true;
        }
        function checkAlLChecked() {
            var Count = document.getElementById("hidControl").value;
            var j = 0;
            var c = 0;
            for (var i = 1; i <= Count; i++) {
                if (document.getElementById("ddlItem" + i).selectedIndex != '0' && document.getElementById("txtQty" + i).value != '' && document.getElementById("txtRateIncTax" + i).value != '') {
                    c++;
                    var checkbx = document.getElementById("chkDelete" + i.toString());
                    if (checkbx.checked == true) {
                        j++;
                    }
                }
            }
            if (j == c) {
                alert("All record can't be deleted !");
                checkbx.checked = false;
            }
        }
        function ValidationInput() {
            if (ValidateItems() == true && ValidateItems1() == true) {
                return true;
            }
            else {
                return false;
            }
        }

        function checkItemRepetion(id) {
            var ddl = document.getElementById(id);
            var currentValue = ddl.options[ddl.selectedIndex].value;
            var Count = document.getElementById("hidControl").value;
            for (var i = 1; i <= Count; i++) {
                var previous = document.getElementById("ddlItem" + i);
                var previousValue = previous.options[previous.selectedIndex].value
                if (ddl != previous) {
                    if (currentValue == previousValue) {
                        alert('Please Select Unique Item');
                        ddl.selectedIndex = 0;
                        break;
                    }
                }
            }
            return true;
        }
    </script>
    <style type="text/css">
        #wrapper
        {
            width: 110%;
            margin-left: 5%;
            margin-top: 15px;
        }
        ul.tabs
        {
            width: 99%;
            margin: 0;
            padding: 0;
        }
        ul.tabs li
        {
            display: block;
            float: left;
            padding: 0 5px;
        }
        ul.tabs li a
        {
            display: block;
            float: left;
            padding: 5px;
            font-size: 0.8em;
            background-color: #e0e0e0;
            color: #666;
            text-decoration: none;
        }
        .selected
        {
            font-weight: bold;
        }
        .tab-content
        {
            clear: both;
            border: 1px solid #ddd;
            padding: 10px;
        }
    </style>
    <%--<script type="text/javascript">

    $(document).ready(function() {

        $('.tabs a').click(function() {
            switch_tabs($(this));
        });

        switch_tabs($('.defaulttab'));

    });

    function switch_tabs(obj) {
        $('.tab-content').hide();
        $('.tabs a').removeClass("selected");
        var id = obj.attr("rel");

        $('#' + id).show();
        obj.addClass("selected");
    }

</script>--%>
    <style type="text/css">
        .AutoExtender
        {
            margin: 0px;
            background-color: White;
            color: windowtext;
            border: 1px solid #006699;
            line-height: 18px;
            padding: 8px;
            border-width: 1px;
            border-style: solid;
            cursor: 'default';
            height: auto;
            min-height: 10px;
            font-family: Verdana, Helvetica, Sans-Serif;
            font-size: .8em;
            font-weight: normal;
            text-align: left;
            list-style-type: none;
        }
        .AutoExtenderList
        {
            border-bottom: solid 1px #006699;
            color: Maroon;
            padding: 1px;
        }
        .AutoExtenderHighlight
        {
            color: White;
            background-color: #006699;
            padding: 1px;
        }
        #Background
        {
            position: fixed;
            top: 0px;
            bottom: 0px;
            left: 0px;
            right: 0px;
            background-color: #E8EAEC;
            opacity: 0.5;
        }
        #Progress
        {
            position: fixed;
            top: 45%;
            margin-left: 350px;
            width: 300px;
            height: 50px;
            text-align: center;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" EnablePageMethods="true"
        runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress DynamicLayout="false" ID="UpdProgress" runat="server">
        <ProgressTemplate>
            <div id="Background" runat="server">
            </div>
            <div align="center" id="Progress">
                <img src="../../Images/ajax-loader.gif" alt="progessbar" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <div class="divmain">
        <acc:heading ID="pagehead" runat="server" HeadingText="Edit Purchase Order" />
    </div>
    <div style="margin-left: 5%; margin-right: 5%; width: 90%" align="center">
        <asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label>
    </div>
    <div style="width: 90%; margin-left: 5%; margin-right: 5%;">
        <div style="margin-left: 5%; margin-right: 5%; width: 90%" align="center">
            <asp:Label ID="Label1" runat="server" Font-Bold="true" EnableViewState="false"></asp:Label>
        </div>
        <center>
            <table class="tablecontent" width="95%">
                <tr>
                    <td class="headtd" colspan="4" align="left">
                        <script type="text/javascript">
                            function EditHappen(ControlID) {
                                document.getElementById(ControlID).style.backgroundColor = "#EE2F24";
                                return true;
                            }
                        </script>
                        <asp:Label ID="lbltitle" runat="server" Text="Purchase Order Details" Width="500px"></asp:Label>
                        <span>Fields marked with <span style="color: Red">*</span> are mandatory</span>
                    </td>
                </tr>
                <tr>
                    <td align="left" width="18%">
                        Bill Format<span style="color: Red">*</span>
                        <asp:HiddenField ID="hidemailid" runat="server" />
                    </td>
                    <td align="left" width="40%">
                        <asp:DropDownList ID="ddlFormat" CssClass="input" runat="server" Width="175px" TabIndex="1"
                            AutoPostBack="true">
                        </asp:DropDownList>
                    </td>
                    <td align="left" width="15%">
                        Supplier<span style="color: Red">*</span>
                    </td>
                    <td align="left" width="25%">
                        <asp:DropDownList ID="ddlSupplier" onchange="return EditHappen(this.id);" CssClass="input"
                            runat="server" Width="175px" AutoPostBack="true" OnSelectedIndexChanged="ddlSupplier_SelectedIndexChanged"
                            TabIndex="4">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Leased Type<span style="color: Red">*</span>
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="ddlleased" onchange="return Change(this.id);" CssClass="input"
                            runat="server" Width="175px" TabIndex="7">
                            <asp:ListItem Value="0" Text="-- Select Type --"></asp:ListItem>
                            <asp:ListItem Value="1" Text="Owned"></asp:ListItem>
                            <asp:ListItem Value="2" Text="Consigned"></asp:ListItem>
                        </asp:DropDownList>
                        <script type="text/javascript">
                            function Change(ID) {
                                if (document.getElementById("ddlleased").selectedIndex == 1) {
                                    document.getElementById("tblconsigned").style.display = "none";
                                    document.getElementById("radioCash").checked = true;
                                    document.getElementById("tblowned").style.display = "block";
                                }
                                if (document.getElementById("ddlleased").selectedIndex == 2) {
                                    document.getElementById("tblconsigned").style.display = "block";
                                    document.getElementById("radioFOC").checked = true;
                                    document.getElementById("tblowned").style.display = "none";
                                }
                                if (document.getElementById("ddlleased").selectedIndex == 0) {
                                    document.getElementById("radioCash").checked = true;
                                    document.getElementById("tblconsigned").style.display = "none";
                                    document.getElementById("tblowned").style.display = "block";
                                }
                                EditHappen(ID);
                            }
                        </script>
                    </td>
                    <td align="left">
                        Delivery Location<span style="color: Red">*</span>
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="DdlLocation" onchange="return EditHappen(this.id);" runat="server"
                            CssClass="input" AutoPostBack="true" Width="175px" OnSelectedIndexChanged="DdlLocation_SelectedIndexChanged"
                            TabIndex="6">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Vendor Quote Ref:
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtvendorref" runat="server" onBlur="return EditHappen(this.id);"
                            Width="172px" CssClass="input" TabIndex="9"></asp:TextBox>
                    </td>
                    <td align="left">
                        Priority
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="DdlPriority" runat="server" onchange="return EditHappen(this.id);"
                            CssClass="input" Width="175px" TabIndex="8">
                            <asp:ListItem Text="Regular" Value="0"></asp:ListItem>
                            <asp:ListItem Text="Urgent" Value="1"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Payment Mode<span style="color: Red">*</span>
                    </td>
                    <td align="left">
                        <table>
                            <tr>
                                <td>
                                    <table id="tblowned" runat="server">
                                        <tr>
                                            <td>
                                                <asp:RadioButton ID="radioCash" Width="80px" runat="server" Checked="true" GroupName="R"
                                                    onclick="if(this.checked){document.getElementById('txtCreditDay').value='';document.getElementById('txtCreditDay').disabled=true;}"
                                                    TabIndex="9" Text="Advance" ToolTip="Advance " />
                                            </td>
                                            <td>
                                                <asp:RadioButton ID="radioCOD" Width="50px" runat="server" GroupName="R" onclick="if(this.checked){document.getElementById('txtCreditDay').disabled=true;}"
                                                    TabIndex="10" Text="COD" ToolTip="Cash On Delivery" />
                                            </td>
                                            <td>
                                                <asp:RadioButton ID="radioCredit" runat="server" Width="60px" GroupName="R" onclick="if(this.checked){document.getElementById('txtCreditDay').value='';document.getElementById('txtCreditDay').disabled=false;}"
                                                    TabIndex="11" Text="Credit" ToolTip="Credit Day" />
                                                <span id="creditday" style="margin-top: 4px;">&nbsp;<asp:TextBox ID="txtCreditDay"
                                                    runat="server" CssClass="inputnumber" Enabled="false" MaxLength="3" onblur="CreditDays()"
                                                    onKeyPress="return isNumberKey(this.id,event)" TabIndex="12" Width="30px"></asp:TextBox>&nbsp;Days
                                                    &nbsp; </span>
                                            </td>
                                        </tr>
                                    </table>
                                    <table id="tblconsigned" style="display: none;" runat="server">
                                        <tr>
                                            <td>
                                                <asp:RadioButton ID="radioFOC" Width="50px" runat="server" Text="FOC" GroupName="R"
                                                    onclick="if(this.checked){document.getElementById('txtCreditDay').disabled=true;}"
                                                    ToolTip="Free Of Cost" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td align="left">
                        Currency
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="ddlcurrency" onchange="return EditHappen(this.id);" runat="server"
                            AutoPostBack="true" CssClass="input" Width="175px" TabIndex="10">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <asp:HiddenField ID="txtPrefix" runat="server" />
                    </td>
                    <td align="left">
                        <asp:HiddenField ID="txtVoucher" runat="server" />
                    </td>
                    <td align="left">
                        <asp:HiddenField ID="txtSuffix" runat="server" />
                    </td>
                    <td align="left">
                        <asp:HiddenField ID="hidmindate" runat="server" />
                    </td>
                </tr>
            </table>
        </center>
    </div>
    <div id="wrapper" style="width: 90%;">
        <ul class="tabs">
            <li><a href="javascript:void(0)" class="defaulttab" rel="tabGeneral">General</a></li>
            <li><a href="javascript:void(0)" rel="tabOther">Other</a></li>
        </ul>
        <div class="tab-content" id="tabGeneral" runat="server">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                    <div>
                        <asp:HiddenField ID="hidControl" Value="5" runat="server" />
                        <asp:HiddenField ID="hidTaxRate0" runat="server" />
                        <table id="tblItem" runat="server" width="100%" class="tablecontent" cellpadding="2"
                            cellspacing="0">
                            <tr>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 35%;">
                                    Item Name
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 15%;">
                                    Unit
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    MPN
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Quantity
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 15%;">
                                    Rate Excl. Tax
                                </td>
                                <td style="border-bottom: 1px solid #818181; text-align: center; font-weight: bold;
                                    width: 15%;">
                                    Amount Payable
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtItem1" onPaste="return false;" onblur="return EditHappen(this.id);"
                                        runat="server" CssClass="input" TabIndex="15" Width="99%" AutoPostBack="true"
                                        OnTextChanged="txtItem_TextChanged"></asp:TextBox>
                                    <AjaxControl:AutoCompleteExtender ID="autoitem1" runat="server" ServiceMethod="GetItemName"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        TargetControlID="txtItem1" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList"
                                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" OnClientItemSelected="duplicaterow"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </AjaxControl:AutoCompleteExtender>
                                    <script type="text/javascript">
                                        function removetext(id) {
                                            document.getElementById("txtItem" + id).value = "";
                                            alert("Enter the Valid Item Name/Item Code.");
                                            document.getElementById("txtItem" + id).focus();
                                        }
                                        function duplicaterow(source, eventArgs) {
                                            try {
                                                var count = 1;
                                                var rowcount = document.getElementById("hidControl").value;
                                                var valuetocheck = eventArgs.get_text();
                                                for (var i = 1; i <= rowcount; i++) {
                                                    if (document.getElementById("txtItem" + i).value != '') {
                                                        if (valuetocheck == document.getElementById("txtItem" + i).value) {
                                                            count++;
                                                            if (count > 2) {
                                                                alert("Duplicate Item Name will not allowed.");
                                                                document.getElementById("txtItem" + i).value = '';
                                                                document.getElementById("txtItem" + i).focus();
                                                                __doPostBack("txtItem" + i, "");
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            catch (error) {

                                            }
                                        }                                            
                                    </script>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtUnit1" runat="server" onblur="return EditHappen(this.id);" TabIndex="17"
                                        Style="background-color: lightGray;" Width="99%" CssClass="input" onKeyPress="return false"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:DropDownList ID="ddlmpn1" runat="server" onchange="EditHappen(this.id);" CssClass="dropdown"
                                        Width="99%">
                                    </asp:DropDownList>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtQty1" runat="server" TabIndex="16" Width="99%" CssClass="inputnumber"
                                        onKeyPress="return isNumber(event)" MaxLength="12" onblur="EditHappen(this.id); calcQty(); calcAmt()"
                                        AutoCompleteType="Disabled"></asp:TextBox>
                                    <script type="text/javascript">
                                        function isNumber(evt) {
                                            var charCode = (evt.which)
                                            //alert(charCode); 
                                            if (charCode == 46 || charCode == 47 || charCode == 44 || charCode == 59) {//&& charCode > 31 && (charCode < 48 || charCode > 57)) {
                                                return false;
                                            }
                                            if (charCode > 65 && charCode < 91) {
                                                return false;
                                            }
                                            if (charCode > 95 && charCode < 121) {
                                                return false;
                                            }
                                            return true;
                                        }
                                    </script>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtRateExcTax1" runat="server" MaxLength="10" TabIndex="18" Width="99%" CssClass="inputnumber"
                                        onKeyPress="return isNumberKey(this.id,event)" AutoCompleteType="Disabled" onblur="EditHappen(this.id); calcRateExcl(); calcAmt()"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtAmountPayable1" runat="server" TabIndex="21" Style="background-color: lightGray;"
                                        Width="97%" CssClass="inputnumber" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtItem2" runat="server" onblur="return EditHappen(this.id);" onPaste="return false;"
                                        CssClass="input" Width="99%" AutoPostBack="true" OnTextChanged="txtItem_TextChanged"></asp:TextBox>
                                    <AjaxControl:AutoCompleteExtender ID="AutoItem2" runat="server" ServiceMethod="GetItemName"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        OnClientItemSelected="duplicaterow" TargetControlID="txtItem2" CompletionListCssClass="AutoExtender"
                                        CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </AjaxControl:AutoCompleteExtender>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtUnit2" runat="server" Style="background-color: lightGray;" CssClass="input"
                                        Width="99%" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:DropDownList ID="ddlmpn2" runat="server" onchange="EditHappen(this.id);" CssClass="dropdown"
                                        Width="99%">
                                    </asp:DropDownList>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtQty2" runat="server" MaxLength="12" CssClass="inputnumber" Width="99%" onKeyPress="return isNumber(event)"
                                        AutoCompleteType="Disabled" onblur="EditHappen(this.id); calcQty(); calcAmt()"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtRateExcTax2" runat="server" MaxLength="10" Width="99%" CssClass="inputnumber"
                                        onKeyPress="return isNumberKey(this.id,event)" AutoCompleteType="Disabled" onblur="EditHappen(this.id); calcRateExcl(); calcAmt()"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtAmountPayable2" Style="background-color: lightGray;" runat="server"
                                        Width="97%" CssClass="inputnumber" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtItem3" runat="server" onblur="EditHappen(this.id);" onPaste="return false;"
                                        Width="99%" CssClass="input" AutoPostBack="true" OnTextChanged="txtItem_TextChanged"></asp:TextBox>
                                    <AjaxControl:AutoCompleteExtender ID="AutoItem3" runat="server" ServiceMethod="GetItemName"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        OnClientItemSelected="duplicaterow" TargetControlID="txtItem3" CompletionListCssClass="AutoExtender"
                                        CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </AjaxControl:AutoCompleteExtender>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtUnit3" runat="server" Style="background-color: lightGray;" Width="99%"
                                        CssClass="input" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:DropDownList ID="ddlmpn3" runat="server" onchange="EditHappen(this.id);" CssClass="dropdown"
                                        Width="99%">
                                    </asp:DropDownList>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtQty3" runat="server" Width="99%" MaxLength="12" CssClass="inputnumber" onblur="EditHappen(this.id); calcQty(); calcAmt()"
                                        onKeyPress="return isNumber(event)" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtRateExcTax3" runat="server" MaxLength="10" Width="99%" CssClass="inputnumber"
                                        onKeyPress="return isNumberKey(this.id,event)" AutoCompleteType="Disabled" onblur="EditHappen(this.id); calcRateExcl(); calcAmt()"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtAmountPayable3" Style="background-color: lightGray;" runat="server"
                                        Width="97%" CssClass="inputnumber" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtItem4" runat="server" onblur="EditHappen(this.id);" onPaste="return false;"
                                        Width="99%" CssClass="input" AutoPostBack="true" OnTextChanged="txtItem_TextChanged"></asp:TextBox>
                                    <AjaxControl:AutoCompleteExtender ID="AutoItem4" runat="server" ServiceMethod="GetItemName"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        TargetControlID="txtItem4" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList"
                                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" OnClientItemSelected="duplicaterow"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </AjaxControl:AutoCompleteExtender>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtUnit4" runat="server" Style="background-color: lightGray;" Width="99%"
                                        CssClass="input" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:DropDownList ID="ddlmpn4" runat="server" onchange="EditHappen(this.id);" CssClass="dropdown"
                                        Width="99%">
                                    </asp:DropDownList>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtQty4" runat="server" Width="99%" MaxLength="12" onblur="EditHappen(this.id); calcQty(); calcAmt()"
                                        CssClass="inputnumber" onKeyPress="return isNumber(event)" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtRateExcTax4" runat="server" MaxLength="10" Width="99%" CssClass="inputnumber"
                                        onKeyPress="return isNumberKey(this.id,event)" AutoCompleteType="Disabled" onblur="EditHappen(this.id); calcRateExcl(); calcAmt()"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtAmountPayable4" Style="background-color: lightGray;" runat="server"
                                        Width="97%" CssClass="inputnumber" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtItem5" runat="server" onblur="EditHappen(this.id);" onPaste="return false;"
                                        Width="99%" CssClass="input" AutoPostBack="true" OnTextChanged="txtItem_TextChanged"></asp:TextBox>
                                    <AjaxControl:AutoCompleteExtender ID="AutoItem5" runat="server" ServiceMethod="GetItemName"
                                        MinimumPrefixLength="1" CompletionInterval="0" EnableCaching="true" FirstRowSelected="false"
                                        TargetControlID="txtItem5" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList"
                                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" OnClientItemSelected="duplicaterow"
                                        ShowOnlyCurrentWordInCompletionListItem="true" DelimiterCharacters=";," CompletionSetCount="20">
                                    </AjaxControl:AutoCompleteExtender>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtUnit5" runat="server" Style="background-color: lightGray;" Width="99%"
                                        CssClass="input" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:DropDownList ID="ddlmpn5" runat="server" onchange="EditHappen(this.id);" CssClass="dropdown"
                                        Width="99%">
                                    </asp:DropDownList>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtQty5" runat="server" Width="99%" MaxLength="12" onblur="EditHappen(this.id); calcQty(); calcAmt()"
                                        CssClass="inputnumber" onKeyPress="return isNumber(event)" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtRateExcTax5" runat="server" MaxLength="10" Width="99%" CssClass="inputnumber"
                                        onblur="EditHappen(this.id); calcRateExcl(); calcAmt()" onKeyPress="return isNumberKey(this.id,event)"
                                        AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                                <td style="vertical-align: top">
                                    <asp:TextBox ID="txtAmountPayable5" Style="background-color: lightGray;" runat="server"
                                        Width="97%" CssClass="inputnumber" onKeyPress="return false" AutoCompleteType="Disabled"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                        <table style="margin: 5px;">
                            <tr>
                                <td>
                                    <asp:LinkButton ID="btnAddMore" runat="server" OnClick="btnAddMore_Click"> 
                                <img src="../../Images/More.jpg" alt="Add New Row" /></asp:LinkButton>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div>
                        <div style="float: left; margin-right: 8%">
                            <table>
                                <tr>
                                    <td>
                                        <strong>Vendor Informations</strong>
                                    </td>
                                    <td>
                                        __________
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="margin-left: 8px">
                                        Opening Balance
                                    </td>
                                    <td style="text-align: right">
                                        <asp:Label ID="lblVenderOB" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:Label ID="lblVenderDrCr" runat="server"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="margin-left: 8px">
                                        Debits
                                    </td>
                                    <td style="text-align: right">
                                        <asp:Label ID="lblVendorDebit" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="margin-left: 8px">
                                        Credits
                                    </td>
                                    <td style="text-align: right">
                                        <asp:Label ID="lblVendorCredit" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="margin-left: 8px">
                                        Closing Balance
                                    </td>
                                    <td style="text-align: right">
                                        <asp:Label ID="lblVenderClosing" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:Label ID="lblVenderDrCr2" runat="server"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="margin-left: 8px">
                                        Credit Limit
                                    </td>
                                    <td style="text-align: right">
                                        <asp:Label ID="lblVendorCreditLimit" runat="server"></asp:Label>
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div style="float: right" align="right">
                            <table>
                                <tr>
                                    <td style="width: 70%">
                                        Item Total
                                    </td>
                                    <td style="width: 30%">
                                        <asp:TextBox ID="txtTotalItem" runat="server" CssClass="inputnumber" onKeyPress="return false"
                                            AutoCompleteType="Disabled" Style="background-color: lightGray;"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Taxable Amount
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtTaxableAmt" runat="server" AutoCompleteType="Disabled" CssClass="inputnumber"
                                            onKeyPress="return false" Style="background-color: lightGray;"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Post Tax Total
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtPostTaxTotal" runat="server" AutoCompleteType="Disabled" CssClass="inputnumber"
                                            onKeyPress="return false" Style="background-color: lightGray;"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Round off Amount
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtRoundoff" runat="server" AutoCompleteType="Disabled" CssClass="inputnumber"
                                            onblur="EditHappen(this.id); RoundOff();" onKeyPress="return isNumberKey(this.id,event)"
                                            Text="0.00"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Grand Total
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtGrandTotal" runat="server" AutoCompleteType="Disabled" CssClass="inputnumber"
                                            onKeyPress="return false" Style="background-color: lightGray;"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
            <div style="clear: both;">
                &nbsp;</div>
        </div>
        <div class="tab-content" id="tabOther" runat="server">
            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <ContentTemplate>
                    <div style="width: 100%;">
                        <div style="float: left; width: 45%;">
                            <table width="100%">
                                <tr>
                                    <td style="width: 30%">
                                        Billing Address<span class="required">*</span>
                                    </td>
                                    <td style="width: 70%">
                                        <asp:TextBox ID="txtBillAddress" runat="server" TextMode="MultiLine" CssClass="input"
                                            Width="97%" Height="60px" onblur="EditHappen(this.id);"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 30%">
                                        Delivery Address<span class="required">*</span>
                                    </td>
                                    <td style="width: 70%">
                                        <asp:TextBox ID="txtDeliveryAdd" runat="server" TextMode="MultiLine" CssClass="input"
                                            Width="97%" Height="60px" onblur="EditHappen(this.id);"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 30%">
                                        Terms of Delivery<span class="required">*</span>
                                    </td>
                                    <td style="width: 70%">
                                        <table width="100%" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td width="100%">
                                                    <asp:DropDownList ID="ddlDeliveryTerms" CssClass="input" runat="server" Width="20%" onchange="EditHappen(this.id);">
                                                        <asp:ListItem></asp:ListItem>
                                                        <asp:ListItem Value="1">EXW</asp:ListItem>
                                                        <asp:ListItem Value="2">FCA</asp:ListItem>
                                                        <asp:ListItem Value="3">CPT</asp:ListItem>
                                                        <asp:ListItem Value="4">CIP</asp:ListItem>
                                                        <asp:ListItem Value="5">DAT</asp:ListItem>
                                                        <asp:ListItem Value="6">DAP</asp:ListItem>
                                                        <asp:ListItem Value="7">FOB</asp:ListItem>
                                                        <asp:ListItem Value="8">CFR</asp:ListItem>
                                                        <asp:ListItem Value="9">CIF</asp:ListItem>
                                                        <asp:ListItem Value="10">DAF</asp:ListItem>
                                                        <asp:ListItem Value="11">DES</asp:ListItem>
                                                        <asp:ListItem Value="12">DEQ</asp:ListItem>
                                                        <asp:ListItem Value="13">DDU</asp:ListItem>
                                                    </asp:DropDownList>
                                                    <asp:TextBox ID="txtDeliveryTerms" runat="server" CssClass="input" Width="76%" onblur="EditHappen(this.id);"></asp:TextBox>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 30%">
                                        Any Special Condition<span class="required">*</span>
                                    </td>
                                    <td style="width: 70%">
                                        <asp:TextBox ID="txtanyspecialcondition" runat="server" onblur="EditHappen(this.id);"
                                            Width="97%" CssClass="input"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div style="width: 55%;">
                            <table style="width: 100%">
                                <tr>
                                    <td style="width: 30%">
                                        Handling &amp; Packing<span class="required">*</span>
                                    </td>
                                    <td style="width: 25%">
                                        <asp:DropDownList ID="ddlhandling" runat="server" onblur="EditHappen(this.id);" CssClass="input">
                                            <asp:ListItem>Inclusive</asp:ListItem>
                                            <asp:ListItem>Exclusive</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <td style="width: 25%">
                                        Tax Duties<span class="required">*</span>
                                    </td>
                                    <td style="width: 20%">
                                        <asp:TextBox ID="txttaxDuties" onblur="EditHappen(this.id);" CssClass="input" Style="background-color: lightGray;
                                            color: Black;" runat="server" Width="85px" Text="Exclusive" onKeyPress="return false;"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        Mode Dispatch<span class="required">*</span>
                                    </td>
                                    <td colspan="3" style="width: 65%">
                                        <asp:RadioButtonList ID="RblModeDispatch" runat="server" onchange="EditHappen(this.id);"
                                            RepeatDirection="Horizontal" onClick="return CheckMode();">
                                            <asp:ListItem Text="Air" Value="1"></asp:ListItem>
                                            <asp:ListItem Text="Sea" Value="2"></asp:ListItem>
                                            <asp:ListItem Text="Road" Value="3"></asp:ListItem>
                                            <asp:ListItem Text="Train" Value="4"></asp:ListItem>
                                            <asp:ListItem Text="Courier" Value="5"></asp:ListItem>
                                            <asp:ListItem Text="Others" Value="0"></asp:ListItem>
                                        </asp:RadioButtonList>
                                        <asp:TextBox ID="txtModeDispatch" runat="server" CssClass="input" Width="97%" Style="display: none;"></asp:TextBox>
                                        <script type="text/javascript">
                                            function CheckMode() {
                                                var RadioValue = document.getElementById("RblModeDispatch");
                                                var RadioTagName = RadioValue.getElementsByTagName("input");
                                                for (var j = 0; j < RadioTagName.length; j++) {
                                                    if (RadioTagName[j].checked) {
                                                        if (RadioTagName[j].value == "0") {
                                                            document.getElementById("txtModeDispatch").style["display"] = "block";
                                                        }
                                                        else {
                                                            document.getElementById("txtModeDispatch").style["display"] = "none";
                                                        }
                                                    }
                                                }
                                            }
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        Delivery Date<span class="required">*</span>
                                    </td>
                                    <td style="width: 65%" colspan="3">
                                        <asp:TextBox ID="txtDeliveryDate" onKeypress="return false;" runat="server" Width="97%"
                                            onblur="EditHappen(this.id);" CssClass="input" ValidationGroup="V"></asp:TextBox>
                                        <AjaxControl:CalendarExtender ID="extCal2" runat="server" TargetControlID="txtDeliveryDate"
                                            Format="dd/MM/yyyy">
                                        </AjaxControl:CalendarExtender>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        Acceptance Criteria<span class="required">*</span>
                                    </td>
                                    <td style="width: 65%" colspan="3">
                                        <asp:RadioButtonList ID="RblAcceptanceCriteria" onchange="EditHappen(this.id);" runat="server"
                                            RepeatDirection="Horizontal" onClick="return CheckAcceptMode();">
                                            <asp:ListItem Text="As Per Quality" Value="1"></asp:ListItem>
                                            <asp:ListItem Text="Others" Value="0"></asp:ListItem>
                                        </asp:RadioButtonList>
                                        <asp:TextBox ID="txtAcceptanceCriteria" runat="server" Width="97%" CssClass="input"
                                            Style="display: none;"></asp:TextBox>
                                        <script type="text/javascript">
                                            function CheckAcceptMode() {
                                                var RadioValue = document.getElementById("RblAcceptanceCriteria");
                                                var RadioTagName = RadioValue.getElementsByTagName("input");
                                                for (var j = 0; j < RadioTagName.length; j++) {
                                                    if (RadioTagName[j].checked) {
                                                        if (RadioTagName[j].value == "0") {
                                                            document.getElementById("txtAcceptanceCriteria").style["display"] = "block";
                                                        }
                                                        else {
                                                            document.getElementById("txtAcceptanceCriteria").style["display"] = "none";
                                                        }
                                                    }
                                                }
                                            }
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        Validity of PO<span class="required">*</span>
                                    </td>
                                    <td style="width: 65%" colspan="3">
                                        <asp:RadioButtonList ID="RblvalidityofPO" runat="server" onchange="EditHappen(this.id);"
                                            RepeatDirection="Horizontal" onClick="return CheckValidityMode();">
                                            <asp:ListItem Text="15 days" Value="1"></asp:ListItem>
                                            <asp:ListItem Text="30 days" Value="2"></asp:ListItem>
                                            <asp:ListItem Text="Others" Value="0"></asp:ListItem>
                                        </asp:RadioButtonList>
                                        <asp:TextBox ID="txtvalidityofPO" runat="server" Width="97%" CssClass="input" Style="display: none;"></asp:TextBox>
                                        <script type="text/javascript">
                                            function CheckValidityMode() {
                                                var RadioValue = document.getElementById("RblvalidityofPO");
                                                var RadioTagName = RadioValue.getElementsByTagName("input");
                                                for (var j = 0; j < RadioTagName.length; j++) {
                                                    if (RadioTagName[j].checked) {
                                                        if (RadioTagName[j].value == "0") {
                                                            document.getElementById("txtvalidityofPO").style["display"] = "block";
                                                        }
                                                        else {
                                                            document.getElementById("txtvalidityofPO").style["display"] = "none";
                                                        }
                                                    }
                                                }
                                            }
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        In Transit Insurance<span class="required">*</span>
                                    </td>
                                    <td style="width: 65%" colspan="3">
                                        <asp:RadioButtonList ID="RblInsurance" runat="server" onchange="EditHappen(this.id);"
                                            RepeatDirection="Horizontal" onClick="return CheckInsuranceMode();">
                                            <asp:ListItem Text="By Supplier Account" Value="1"></asp:ListItem>
                                            <asp:ListItem Text="By Buyer Account" Value="2"></asp:ListItem>
                                            <asp:ListItem Text="Others" Value="0"></asp:ListItem>
                                        </asp:RadioButtonList>
                                        <asp:TextBox ID="txtInsurance" runat="server" Width="97%" CssClass="input" Style="display: none;"></asp:TextBox>
                                        <script type="text/javascript">
                                            function CheckInsuranceMode() {
                                                var RadioValue = document.getElementById("RblInsurance");
                                                var RadioTagName = RadioValue.getElementsByTagName("input");
                                                for (var j = 0; j < RadioTagName.length; j++) {
                                                    if (RadioTagName[j].checked) {
                                                        if (RadioTagName[j].value == "0") {
                                                            document.getElementById("txtInsurance").style["display"] = "block";
                                                        }
                                                        else {
                                                            document.getElementById("txtInsurance").style["display"] = "none";
                                                        }
                                                    }
                                                }
                                            }
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        Warranty<span class="required">*</span>
                                    </td>
                                    <td style="width: 65%" colspan="3">
                                        <asp:RadioButtonList ID="RblWarranty" runat="server" onchange="EditHappen(this.id);"
                                            RepeatDirection="Horizontal" onClick="return CheckWarrantyMode();">
                                            <asp:ListItem Text="By Supplier Account" Value="1"></asp:ListItem>
                                            <asp:ListItem Text="By Buyer Account" Value="2"></asp:ListItem>
                                            <asp:ListItem Text="Others" Value="0"></asp:ListItem>
                                        </asp:RadioButtonList>
                                        <asp:TextBox ID="txtWarranty" runat="server" Width="97%" CssClass="input" Style="display: none;"></asp:TextBox>
                                        <script type="text/javascript">
                                            function CheckWarrantyMode() {
                                                var RadioValue = document.getElementById("RblWarranty");
                                                var RadioTagName = RadioValue.getElementsByTagName("input");
                                                for (var j = 0; j < RadioTagName.length; j++) {
                                                    if (RadioTagName[j].checked) {
                                                        if (RadioTagName[j].value == "0") {
                                                            document.getElementById("txtWarranty").style["display"] = "block";
                                                        }
                                                        else {
                                                            document.getElementById("txtWarranty").style["display"] = "none";
                                                        }
                                                    }
                                                }
                                            }
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 30%">
                                        Freight Forwarders<span class="required">*</span>
                                    </td>
                                    <td style="width: 25%">
                                        <asp:TextBox ID="txtfreightfwd" runat="server" onblur="EditHappen(this.id);" CssClass="input"
                                            Width="91px"></asp:TextBox>
                                    </td>
                                    <td style="width: 25%">
                                        Import Account No<span class="required">*</span>
                                    </td>
                                    <td style="width: 20%">
                                        <asp:TextBox ID="txtimpacno" runat="server" onblur="EditHappen(this.id);" CssClass="input"
                                            Width="85px"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        Remarks
                                    </td>
                                    <td style="width: 65%" colspan="3">
                                        <asp:TextBox ID="txtRemark" onblur="EditHappen(this.id);" runat="server" Width="97%"
                                            CssClass="input"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 15%">
                                        Freight<span class="required">*</span>
                                    </td>
                                    <td style="width: 65%" colspan="3">
                                        <asp:RadioButtonList ID="RBLFreight" runat="server" RepeatDirection="Horizontal"
                                            onClick="return CheckFreightMode();" onchange="EditHappen(this.id);">
                                            <asp:ListItem Text="Exclusive" Value="1"></asp:ListItem>
                                            <asp:ListItem Text="Inclusive" Value="2"></asp:ListItem>
                                            <asp:ListItem Text="Others" Value="0"></asp:ListItem>
                                        </asp:RadioButtonList>
                                        <asp:TextBox ID="txtfreight" runat="server" Width="97%" CssClass="input" Style="display: none;"></asp:TextBox>
                                        <script type="text/javascript">
                                            function CheckFreightMode() {
                                                var RadioValue = document.getElementById("RBLFreight");
                                                var RadioTagName = RadioValue.getElementsByTagName("input");
                                                for (var j = 0; j < RadioTagName.length; j++) {
                                                    if (RadioTagName[j].checked) {
                                                        if (RadioTagName[j].value == "0") {
                                                            document.getElementById("txtfreight").style["display"] = "block";
                                                        }
                                                        else {
                                                            document.getElementById("txtfreight").style["display"] = "none";
                                                        }
                                                    }
                                                }
                                            }
                                        </script>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
            <div style="clear: both">
                &nbsp;</div>
        </div>
        <div style="width: 98%">
            <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                <ContentTemplate>
                    <table style="width: 98%; text-align: center">
                        <tr>
                            <td>
                                <asp:Button ID="btnUpdate" Text="Update" runat="server" CssClass="button" OnClientClick="return ValidationInput();"
                                    OnClick="btnUpdate_Click" ValidationGroup="V" />
                                &nbsp;
                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CssClass="button" OnClick="btnCancel_Click" />
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>
    </form>
</body>
</html>
